---
description: "Reference for Nitric's v0 .NET library - Store a new secret value"
---

# .NET - Secret.Put()

Store a new secret value, creating a new [version](./secret-version) to store the value.

```csharp
using Nitric.Sdk;
using Nitric.Sdk.Resource;

var keyRef = Nitric.Secret("apiKey").With(SecretPermission.Putting);

keyRef.Put("6c3199a3-094e-4797-bfc9-9ee2a7839286");

Nitric.Run();
```

## Parameters

<Properties>
  <Property name="secret" required type="string">
    The new secret value to store in the secrets manager.
  </Property>
</Properties>

### Notes

A new secret version is always created when calling `Put()`, the versions will automatically be provided a unique id. This behavior is dependent on the underlying secrets manager.

## Examples

### Store a new secret value

```csharp
using Nitric.Sdk;
using Nitric.Sdk.Resource;

var keyRef = Nitric.Secret("apiKey").With(SecretPermission.Putting);

keyRef.Put("6c3199a3-094e-4797-bfc9-9ee2a7839286");

Nitric.Run();
```

### Get the id of a new secret version

Calling `Put()` returns a promise to a reference to the new secret version. Storing the ID of the new version can be useful if you need to retrieve that specific value again in future using [version.access()](./secret-version-access)

```csharp
using Nitric.Sdk;
using Nitric.Sdk.Resource;

var keyRef = Nitric.Secret("apiKey").With(SecretPermission.Putting);

var newApiKeyVersionRef = keyRef.Put("6c3199a3-094e-4797-bfc9-9ee2a7839286");

var versionId = newApiKeyVersionRef.Id;

Nitric.Run();
```
